unit u_sucrouf;

interface

uses

system.Drawing,
u_animsprite,
system.windows.Forms,
Microsoft.DirectX,
Microsoft.DirectX.Direct3D,
Microsoft.DirectX.Direct3DX;


type



c_surcouf = class

  private

    _sprite: sprite;
    fond: texture;
    fond_sur: texture;
    icone: texture;
    b_save: c_animsprite;
    b_non: c_animsprite;
    b_oui: c_animsprite;
    visible: boolean;
    goto_surcouf: boolean;

  public

    constructor create(dev: device; width, height: integer);
    procedure show_sauvegarde;
    procedure onclick(mousex, mousey, width, height: integer);
    procedure onresize(width, height: integer);
    procedure sur_bouton(mousex, mousey, width, height: integer);
    procedure aff_surcouf(width, height: integer);


end;


implementation


constructor c_surcouf.create;
begin
  inherited create;
  _sprite := sprite.Create(dev);
  fond := Textureloader.FromFile(dev, 'asus menu\menu_princ\fond.png)');
  icone := TextureLoader.FromFile(dev, 'asus menu\surcouf\logo_surcouf.png');
  fond_sur := TextureLoader.FromFile(dev, 'asus menu\surcouf\fond_sur.png');
  b_save := c_animsprite.create(dev, 'asus menu\menu_prunc\save.png', 'asus menu\menu_princ\save.png', 2 * height div 5, width div 2 - 137);
  b_non := c_animsprite.create(dev, 'asus menu\menu_princ\non.png', 'asus menu\menu_princ\non1.png', 2 * height div 5, width div 2 + 5);
  b_oui := c_animsprite.create(dev, 'asus menu\menu_princ\oui.png', 'asus menu\menu_princ\oui1.png', 2 * height div 5 + 20, width div 2 - 140);
  visible := false;
  goto_surcouf := false;
end;


procedure c_surcouf.show_sauvegarde;
begin
  _sprite.&Begin(SpriteFlags.AlphaBlend);
    _sprite.Draw(fond, Vector3.Create(0, 0 ,0), Vector3.Create(0, 0 ,0), color.White.ToArgb);
  _sprite.&End;
  if b_save.est_dehors then
    begin
      b_save.faire_venir;
      b_non.faire_venir;
      b_oui.faire_venir;
    end;
  b_save.render;
  b_non.render;
  b_oui.render;


end;

procedure c_surcouf.onresize(width: Integer; height: Integer);
begin
  b_save.change_resolution(width, height, width div 2 - 137, 2 * height div 5);
  b_non.change_resolution(width, height, width div 2 - 140, 2 * height div 5 + 20);
  b_oui.change_resolution(width, height, width div 2 + 5, 2 * height div 5 + 20);

  if goto_surcouf then
    begin
      b_save.set_out;
      b_non.set_out;
      b_oui.set_out;
    end;
end;


procedure c_surcouf.onclick(mousex, mousey, width: Integer; height: Integer);
begin
  if visible then
    begin
      if (mousex >= width div 2 + 5) and (mousex <= width div 2 - 140 + 137) and
         (mousey >= 2 * height div 5 + 20) and (mousey <= 2 * height div 5 + 20 + 15)  then
          begin
           if b_non.est_dedans then
             begin
               b_save.faire_sortir;
               b_non.faire_sortir;
               b_oui.faire_sortir;
               goto_surcouf := true;
             end;
          end;
      if (mousex >= width div 2 + 5) and (mousex <= width div 2 + 5 + 137) and
         (mousey >= 2 * height div 5 + 20) and (mousey <= 2 * height div 5 + 20 + 15)  then
          begin
           if b_oui.est_dedans then
             begin
               //func mutun
               b_save.faire_sortir;
               b_non.faire_sortir;
               b_oui.faire_sortir;
               goto_surcouf := true;
             end;
          end;
    end;
end;

procedure c_surcouf.sur_bouton(mousex, mousey, width: Integer; height: Integer);
begin
  if (mousex >= width div 2 - 137) and (mousex <= width div 2 - 137 + 275) and
     (mousey >= 2 * height div 5) and (mousey <= height div 5 + 30)  then
      begin
       if b_save.est_dedans then
         b_save.pause;
      end
  else
    b_save.play;
  if (mousex >= width div 2 + 5) and (mousex <= width div 2 - 140 + 137) and
     (mousey >= 2 * height div 5 + 20) and (mousey <= 2 * height div 5 + 20 + 15)  then
      begin
       if b_non.est_dedans then
         b_non.pause;
      end
  else
    b_non.play;
  if (mousex >= width div 2 + 5) and (mousex <= width div 2 + 5 + 137) and
     (mousey >= 2 * height div 5 + 20) and (mousey <= 2 * height div 5 + 20 + 15)  then
      begin
       if b_oui.est_dedans then
         b_oui.pause;
      end
  else
    b_oui.play;
end;

procedure c_surcouf.aff_surcouf;
begin
  if b_save.est_dehors and
     b_non.est_dehors and
     b_oui.est_dehors then
      begin
        _sprite.&Begin(SpriteFlags.AlphaBlend);
          _sprite.Draw(fond_sur, vector3.Create(0, 0, 0), Vector3.Create(0, 0, 0), color.White.ToArgb);
         _sprite.Draw(icone, Vector3.Create(0, 0, 0), Vector3.Create(width div 2, 40, 0), color.White.ToArgb);
        _sprite.&End
      end;
end;



end.
